package com.xcc.annotation.ioc.config;

import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

public class Demo01_MyTypeFilter implements TypeFilter {

    /**
     *
     * @param metadataReader        读取到的当前正在扫描的类的信息
     * @param metadataReaderFactory 可以获取到其他任何类信息的
     */
    @Override
    public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {
        AnnotationMetadata annotationMetadata = metadataReader.getAnnotationMetadata();
        //获取类名
        String className = annotationMetadata.getClassName();
//        System.out.println("......"+className);
        if (className.contains("Dao")) {
            return true;
        }
        return false;
    }
}
